<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div id="app">
    <h2>总价格{{TotalPrice}}</h2>
</div>

<script src="../js/vue.js"></script>
<script>
    const  app = new Vue({
      el:'#app',
      data:{
        books: [
          {id: 110, name: '代码大全', price: 520},
          {id: 10, name: '小学教程', price: 50},
          {id: 11, name: '七朵水仙花', price: 51},
        ]
      },
      computed: {
        TotalPrice: function () {
          let  rs = 0
           for (let i = 0;  i < this.books.length; i++){
             rs += this.books[i].price
           }
           return rs
        }
      }
    })
</script>

</body>
</html>